package com.lx.chong.controller;

import com.lx.chong.common.Result;
import com.lx.chong.enums.ResultEnum;
import com.lx.chong.model.ProConfig;
import com.lx.chong.service.impl.ProConfigServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chong
 * @create 2019/6/17
 * Desc:
 */
@Slf4j
@RestController
public class ProConfigController {
    @Autowired
    private ProConfigServiceImpl proConfigService;

    /**
     * 获取配置
     * @param id
     * @return
     */
    @PostMapping("/getProConfigById")
    public Result getProConfigById(@RequestBody Long id) {
        Result result = new Result();
        try {
            ProConfig one = proConfigService.findOne(id);
            result.setData(one);
        } catch (Exception e) {
            result.setCode(ResultEnum.OPERATION_ERROR.getCode());
            result.setMsg("获取配置异常");
            log.error(e.getMessage());
        }
        return result;
    }
}
